<?php
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thêm laptop</title>
</head>

<body>
<?php
$idxoa = $_GET["idxoa"];
include("kn.php");



$lenh = "select * from laptop where malaptop='$idxoa'";
$kq = mysql_query($lenh);
$row = mysql_fetch_array($kq);


if(isset($_POST["xoa"]))
{
	$lenhxoa = "delete1 from laptop where malaptop='$idxoa'";
	$kqxoa = mysql_query($lenhxoa);
	
	if($kqxoa)
	{
		?>
        <script>
		alert('Xoá thành công!');
		</script>
        <?php
		header("refresh:2,url=thongtinlaptop.php");
	}
	else
	{
	?>
        <script>
		alert('Xoá thất bại!');
		</script>
        <?php
			header("refresh:2,url=thongtinlaptop.php");
	}
	
}


?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="550" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFCCCC" bordercolor="#FFFF99" style="border-collapse:collapse">
    <tr>
      <td height="40" colspan="2" align="center" bgcolor="#FF99CC"><strong>XOÁ LAPTOP</strong></td>
    </tr>
    <tr>
      <td width="195" style="padding-left:15px">Mã laptop</td>
      <td width="349"><label for="malaptop"></label>
      <input name="malaptop" type="text" id="malaptop" size="40" value="<?php echo $idxoa;   ?>" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Tên laptop</td>
      <td><label for="tenlaptop"></label>
      <input name="tenlaptop" type="text" id="tenlaptop" size="50" value="<?php echo $row[Tenlaptop];   ?>" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Hãng laptop</td>
      <td><label for="hang"></label>
        <select name="hang" id="hang">
        <?php
		include("kn.php");
		$lenhhang = "select * from hanglaptop";
		$kqhang = mysql_query($lenhhang);
		while($rowhang = mysql_fetch_row($kqhang))
		{
			if($row[Mahanglaptop]==$rowhang[0])
			
			echo " <option value='$rowhang[0]'selected>$rowhang[1]</option>";
			else
			echo " <option value='$rowhang[0]'>$rowhang[1]</option>";
		}
		
		?>
       
      </select></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Loại laptop</td>
      <td><label for="loai"></label>
        <select name="loai" id="loai">
         <?php
		include("kn.php");
		$lenhloai = "select * from loailaptop";
		$kqloai = mysql_query($lenhloai);
		while($rowloai = mysql_fetch_row($kqloai))
		{
			if($row[Maloailaptop]==$rowloai[0])
			echo " <option value='$rowloai[0]'selected>$rowloai[1]</option>";
			else
			if($row[Maloailaptop]==$rowloai[0])
			echo " <option value='$rowloai[0]'>$rowloai[1]</option>";
		}
		
		?>
      </select></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Mô tả</td>
      <td><label for="mota"></label>
      <textarea name="mota" cols="30" rows="3" id="mota"><?php echo $row[Mota];   ?></textarea></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Số lượng</td>
      <td><label for="soluong"></label>
      <input type="text" name="soluong" id="soluong" value="<?php echo $row[Soluong];   ?>" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Đơn giá</td>
      <td><label for="dongia"></label>
      <input type="text" name="dongia" id="dongia" value="<?php echo $row[Dongia];   ?>" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Hình</td>
      <td><label for="hinh"></label>
      <input type="file" name="hinh" id="hinh" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Ngày nhập</td>
      <td><label for="ngay">Ngày</label>
        <select name="ngay" id="ngay">
        <?php
		for($i = 1; $i <= 31; $i++)
		{
			if($i==date("d"))
			echo " <option selected>$i</option>";
			else
			echo " <option>$i</option>";
		}
		
		?>
       
      </select>
        <label for="thang">Tháng</label>
        <select name="thang" id="thang">
        <?php
		for($i = 1; $i <= 12; $i++)
		{
			if($i==date("m"))
			echo " <option selected>$i</option>";
			else
			echo " <option>$i</option>";
		}
		
		?>
      </select>
        <label for="nam">Năm</label>
        <select name="nam" id="nam">
        <?php
		for($i = 1975; $i <= 2015; $i++)
		{
			if($i==date("Y"))
			echo " <option selected>$i</option>";
			else
			echo " <option>$i</option>";
		}
		
		?>
      </select></td>
    </tr>
    <tr>
      <td height="35" colspan="2" align="center"><input type="submit" name="xoa" id="xoa" value="Xoá" /></td>
    </tr>
  </table>
</form>
</body>
</html>